//
//  JHXiangQingTableViewCell.m
//  Liberty Voice
//
//  Created by dlios on 15-5-27.
//  Copyright (c) 2015年 ClearLove. All rights reserved.
//

#import "JHXiangQingTableViewCell.h"
#import "UIImageView+WebCache.h"


@interface JHXiangQingTableViewCell ()

@property(nonatomic,retain)UIImageView *aboutbact;
@property(nonatomic,retain)UIImageView *aboutImage;
@property(nonatomic,retain)UIImageView *Image1;
@property(nonatomic,retain)UILabel *aboutLabel;
@property(nonatomic,retain)UILabel *aboutLabel2;
@property(nonatomic,retain)UIImageView *Image2;
@property(nonatomic,retain)UILabel *aboutLabel3;

@end

@implementation JHXiangQingTableViewCell
- (void)dealloc
{
    [_aboutbact release];
    [_aboutImage release];
    [_Image1 release];
    [_aboutLabel release];
    [_aboutLabel2 release];
//    [_aboutButton release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //        self.aboutbact = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_share_large"]] autorelease];
        //        [self.contentView addSubview:_aboutbact];
        //  头像
        self.aboutImage = [[[UIImageView alloc] init]autorelease];
        _aboutImage.image = [UIImage imageNamed:@"iconfont-play"];
        _aboutImage.layer.cornerRadius = 24.5;
        _aboutImage.layer.masksToBounds = YES;
        //        _recomImage.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_aboutImage];
        //  标题
        self.aboutLabel = [[[UILabel alloc] init] autorelease];
        //        _aboutLabel.backgroundColor = [UIColor yellowColor];
        _aboutLabel.font = [UIFont systemFontOfSize:15];
        _aboutLabel.numberOfLines = 0;
        [self.contentView addSubview:_aboutLabel];
        //  播放图片
        self.Image1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-play"]];
        [self.contentView addSubview:_Image1];
        //  播放次数
        self.aboutLabel2 = [[[UILabel alloc] init] autorelease];
        _aboutLabel2.font = [UIFont systemFontOfSize:10];
        //        _aboutLabel2.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_aboutLabel2];
        //  人数
        self.Image2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-xiai"]];
        [self.contentView addSubview:_Image2];
        //  播放次数
        self.aboutLabel3 = [[[UILabel alloc] init] autorelease];
        _aboutLabel3.font = [UIFont systemFontOfSize:10];
        //        _aboutLabel2.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_aboutLabel3];
        //  收藏按钮
//        self.aboutButton = [UIButton buttonWithType:UIButtonTypeSystem];
//        [_aboutButton setTitle:@"收藏" forState:UIControlStateNormal];
//        //        _aboutButton.tag = 1000;
//        [self.contentView addSubview:_aboutButton];
        
    }return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    //    _aboutbact.frame = CGRectMake(0, 5, self.contentView.frame.size.width, self.contentView.frame.size.height - 10);
    _aboutImage.frame = CGRectMake(10, 10, self.contentView.frame.size.width / 5 - 20, self.contentView.frame.size.width / 5 - 20);
    _aboutLabel.frame = CGRectMake(_aboutImage.frame.size.width + 20 , 15, self.contentView.frame.size.width - _aboutImage.frame.size.width - 30, 30);
    _Image1.frame = CGRectMake(_aboutImage.frame.size.width + 20 , _aboutLabel.frame.origin.y + 45, 15, 15);
    _aboutLabel2.frame = CGRectMake(_Image1.frame.origin.x + 20, _aboutLabel.frame.origin.y + 45, self.contentView.frame.size.width / 4, 15);
    _Image2.frame = CGRectMake(_aboutLabel2.frame.origin.x + self.contentView.frame.size.width / 4 , _aboutLabel.frame.origin.y + 45, 15, 15);
    _aboutLabel3.frame = CGRectMake(_Image2.frame.origin.x + 20, _aboutLabel.frame.origin.y + 45, self.contentView.frame.size.width / 4, 15);
    _aboutButton.frame = CGRectMake(self.contentView.frame.size.width / 5 *4, _aboutLabel2.frame.origin.y + 25, self.contentView.frame.size.width / 5, 15);
    
}
- (void)setXiangQing:(JHxiangqing *)xiangQing
{
    if (xiangQing != _xiangQing) {
        [_xiangQing release];
        _xiangQing = [xiangQing retain];
    }
    [_aboutImage sd_setImageWithURL:[NSURL URLWithString:xiangQing.albumCoverUrl290]];
    _aboutLabel.text = xiangQing.title;
    NSString *num = @"";
    if (xiangQing.playsCounts < 10000) {
        num = [NSString stringWithFormat:@"%ld",xiangQing.playsCounts];
    }else
        if (xiangQing.playsCounts > 10000) {
            //            NSInteger a = (recom.playsCounts / 10000.00);
            num = [NSString stringWithFormat:@"%.1f万",xiangQing.playsCounts / 10000.0];
        }
    
    _aboutLabel2.text = num;
    _aboutLabel3.text = [xiangQing.tracksCounts description];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
